package com.bjsxt.chapter4_prototype;

import java.util.Date;

/**
 * @ClassName Client2
 * @Description 测试原型模式，深克隆
 * 深克隆就是不仅仅只是克隆对象的属性的引用地址和常量，对象的属性以及属性的属性也一起克隆
 * @Author 黑马程序员
 * @Date 11:06 2024/6/21
 * @Version 1.0
 **/
public class Client2 {
    public static void main(String[] args) {
        Date date = new Date(12312321331L);
        try {
            Sheep2 s1 = new Sheep2(date, "少利");
            Sheep2 s2 = (Sheep2) s1.clone();
            s2.setName("多利");

            System.out.println(s1);
            System.out.println(s1.getName());
            System.out.println(s1.getBirthDay());
            date.setTime(23423423423L);
            System.out.println(s1.getBirthDay());

            System.out.println(s2);
            System.out.println(s2.getName());
            System.out.println(s2.getBirthDay());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}
